{% extends 'basic.html' %}
{% load static %}

{% block title %}
    用户名密码登录
{% endblock %}


{% block css %}
    <link rel="stylesheet" href="{% static 'css/account.css' %}">
    <style>
        .account{
            border-radius: 15px;
            margin-top: 80px;
            box-shadow: 15px 15px 15px 10px lightgray;
        }
        .error-msg{
            color: red;
        }
        .login_sms{
            font-style: italic;
        }
        .login_sms:hover{
            text-decoration: none;
        }
    </style>
{% endblock %}


{% block content %}
       <div class="account">
            <div class="title">用户名密码登录</div>
            <form id="pwdForm" method="POST" novalidate>
                {% csrf_token %}
                {% for field in form %}
                    {% if field.name == 'img_code' %}
                        <div class="form-group">
                            <label for="{{ field.id_for_label }}">{{ field.label }}</label>
                            <div class="row ">
                                <div class="col-xs-7" style="margin-left: 13px; width: 300px">
                                    {{ field }}
                                    <span class="error-msg">{{ field.errors.0 }}</span>
                                </div>
                                <div class="col-xs-5" style="margin-left: 80px;border: 1px lightgray solid">
                                    <img src="{% url 'img_code' %}" id="img_code" title="点击更换图片">
                                </div>
                            </div>
                        </div>
                    {% else %}
                        <div class="form-group">
                            <label for="{{ field.id_for_label }}">{{ field.label }}</label>
                            {{ field }}
                            <span class="error-msg">{{ field.errors.0 }}</span>
                        </div>
                    {% endif %}
                {% endfor %}
                <div class="row">
                    <div class="cols-xl-3" style="margin-left: 13px">
                        <input type="submit" value="登  录" class="btn-primary btn">
                    </div>
                    <div class="col-xs-3" style="margin-left: 320px">
                        <a href="{% url 'login' %}" class="login_sms">短信验证码登录</a>
                    </div>
                </div>
            </form>
    </div>
{% endblock %}


{% block js %}
    <script>
        $(function () {
            $('#img_code').click(function () {
                var oldSrc = $(this).attr('src');
                $(this).attr('src', oldSrc + '?')
            })
        })
    </script>
{% endblock %}